package com.cuijq.ms.singleton.generator;

import java.util.concurrent.atomic.AtomicLong;

/**
 * @Classname IdGenerator3
 * @Description 静态内部类
 * @Date 2021/5/5 9:46
 * @Created by CuiJQ
 */
public class IdGenerator3 {

  private AtomicLong id = new AtomicLong(0);

  private IdGenerator3() {
  }

  private static class SingletonHolder {

    private static final IdGenerator3 instance = new IdGenerator3();
  }

  public static IdGenerator3 getInstance() {
    return SingletonHolder.instance;
  }

  public long getId() {
    return id.incrementAndGet();
  }
}
